.class Lcom/nemustech/regina/AppInfoManager$AppLoader;
.super Ljava/lang/Object;
.source "AppInfoManager.java"

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/nemustech/regina/AppInfoManager;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x2
    name = "AppLoader"
.end annotation


# instance fields
.field private volatile mRunning:Z

.field private volatile mStopped:Z

.field final synthetic this$0:Lcom/nemustech/regina/AppInfoManager;


# direct methods
.method constructor <init>(Lcom/nemustech/regina/AppInfoManager;)V
    .locals 1
    .parameter

    .prologue
    .line 546
    iput-object p1, p0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 547
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->mRunning:Z

    .line 548
    return-void
.end method


# virtual methods
.method public isRunning()Z
    .locals 1

    .prologue
    .line 555
    iget-boolean v0, p0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->mRunning:Z

    return v0
.end method

.method public run()V
    .locals 19

    .prologue
    .line 560
    const/4 v4, 0x1

    move v0, v4

    move-object/from16 v1, p0

    iput-boolean v0, v1, Lcom/nemustech/regina/AppInfoManager$AppLoader;->mRunning:Z

    .line 561
    const/4 v4, 0x0

    move v0, v4

    move-object/from16 v1, p0

    iput-boolean v0, v1, Lcom/nemustech/regina/AppInfoManager$AppLoader;->mStopped:Z

    .line 563
    const/4 v4, 0x1

    invoke-static {v4}, Landroid/os/Process;->setThreadPriority(I)V

    .line 564
    new-instance v17, Landroid/content/Intent;

    const-string v4, "android.intent.action.MAIN"

    const/4 v5, 0x0

    move-object/from16 v0, v17

    move-object v1, v4

    move-object v2, v5

    invoke-direct {v0, v1, v2}, Landroid/content/Intent;-><init>(Ljava/lang/String;Landroid/net/Uri;)V

    .line 565
    .local v17, mainIntent:Landroid/content/Intent;
    const-string v4, "android.intent.category.LAUNCHER"

    move-object/from16 v0, v17

    move-object v1, v4

    invoke-virtual {v0, v1}, Landroid/content/Intent;->addCategory(Ljava/lang/String;)Landroid/content/Intent;

    .line 566
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    invoke-static {v4}, Lcom/nemustech/regina/AppInfoManager;->access$400(Lcom/nemustech/regina/AppInfoManager;)Landroid/content/pm/PackageManager;

    move-result-object v4

    const/4 v5, 0x0

    move-object v0, v4

    move-object/from16 v1, v17

    move v2, v5

    invoke-virtual {v0, v1, v2}, Landroid/content/pm/PackageManager;->queryIntentActivities(Landroid/content/Intent;I)Ljava/util/List;

    move-result-object v10

    .line 567
    .local v10, apps:Ljava/util/List;,"Ljava/util/List<Landroid/content/pm/ResolveInfo;>;"
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    const/4 v5, 0x0

    invoke-static {v4, v5}, Lcom/nemustech/regina/AppInfoManager;->access$002(Lcom/nemustech/regina/AppInfoManager;Z)Z

    .line 568
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    invoke-static {v4}, Lcom/nemustech/regina/AppInfoManager;->access$900(Lcom/nemustech/regina/AppInfoManager;)Ljava/util/List;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/List;->clear()V

    .line 570
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    invoke-static {v4}, Lcom/nemustech/regina/AppInfoManager;->access$1000(Lcom/nemustech/regina/AppInfoManager;)Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;

    move-result-object v4

    if-eqz v4, :cond_0

    .line 571
    invoke-static {}, Lcom/nemustech/regina/AppInfoManager;->access$800()Landroid/os/Handler;

    move-result-object v4

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v5, v0

    invoke-static {v5}, Lcom/nemustech/regina/AppInfoManager;->access$1000(Lcom/nemustech/regina/AppInfoManager;)Lcom/nemustech/regina/AppInfoManager$BitmapCacheLoader;

    move-result-object v5

    invoke-virtual {v4, v5}, Landroid/os/Handler;->removeCallbacks(Ljava/lang/Runnable;)V

    .line 574
    :cond_0
    if-eqz v10, :cond_3

    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->mStopped:Z

    move v4, v0

    if-nez v4, :cond_3

    .line 576
    const-string v4, "AppInfoManager"

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    const-string v6, "=================== AppLoader start =================== target size : "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-interface {v10}, Ljava/util/List;->size()I

    move-result v6

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    const/4 v6, 0x0

    invoke-static {v4, v5, v6}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 578
    invoke-interface {v10}, Ljava/util/List;->size()I

    move-result v13

    .line 579
    .local v13, count:I
    const/4 v15, 0x0

    .local v15, i:I
    :goto_0
    if-ge v15, v13, :cond_1

    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->mStopped:Z

    move v4, v0

    if-nez v4, :cond_1

    .line 580
    invoke-interface {v10, v15}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v16

    check-cast v16, Landroid/content/pm/ResolveInfo;

    .line 581
    .local v16, info:Landroid/content/pm/ResolveInfo;
    new-instance v9, Lcom/nemustech/regina/AppInfo;

    invoke-direct {v9}, Lcom/nemustech/regina/AppInfo;-><init>()V

    .line 582
    .local v9, application:Lcom/nemustech/regina/AppInfo;
    move-object/from16 v0, v16

    iget-object v0, v0, Landroid/content/pm/ResolveInfo;->activityInfo:Landroid/content/pm/ActivityInfo;

    move-object v4, v0

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v5, v0

    invoke-static {v5}, Lcom/nemustech/regina/AppInfoManager;->access$400(Lcom/nemustech/regina/AppInfoManager;)Landroid/content/pm/PackageManager;

    move-result-object v5

    invoke-virtual {v4, v5}, Landroid/content/pm/ActivityInfo;->loadLabel(Landroid/content/pm/PackageManager;)Ljava/lang/CharSequence;

    move-result-object v4

    iput-object v4, v9, Lcom/nemustech/regina/AppInfo;->title:Ljava/lang/CharSequence;

    .line 583
    new-instance v12, Landroid/content/ComponentName;

    move-object/from16 v0, v16

    iget-object v0, v0, Landroid/content/pm/ResolveInfo;->activityInfo:Landroid/content/pm/ActivityInfo;

    move-object v4, v0

    iget-object v4, v4, Landroid/content/pm/ActivityInfo;->applicationInfo:Landroid/content/pm/ApplicationInfo;

    iget-object v4, v4, Landroid/content/pm/ApplicationInfo;->packageName:Ljava/lang/String;

    move-object/from16 v0, v16

    iget-object v0, v0, Landroid/content/pm/ResolveInfo;->activityInfo:Landroid/content/pm/ActivityInfo;

    move-object v5, v0

    iget-object v5, v5, Landroid/content/pm/ActivityInfo;->name:Ljava/lang/String;

    invoke-direct {v12, v4, v5}, Landroid/content/ComponentName;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    .line 586
    .local v12, componentName:Landroid/content/ComponentName;
    const/high16 v4, 0x1020

    invoke-virtual {v9, v12, v4}, Lcom/nemustech/regina/AppInfo;->setActivity(Landroid/content/ComponentName;I)V

    .line 592
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    invoke-static {v4}, Lcom/nemustech/regina/AppInfoManager;->access$900(Lcom/nemustech/regina/AppInfoManager;)Ljava/util/List;

    move-result-object v4

    invoke-interface {v4, v9}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 579
    add-int/lit8 v15, v15, 0x1

    goto :goto_0

    .line 594
    .end local v9           #application:Lcom/nemustech/regina/AppInfo;
    .end local v12           #componentName:Landroid/content/ComponentName;
    .end local v16           #info:Landroid/content/pm/ResolveInfo;
    :cond_1
    const-string v4, "AppInfoManager"

    const-string v5, "=================== AppLoader finished ==================="

    const/4 v6, 0x0

    invoke-static {v4, v5, v6}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 596
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    invoke-static {v4}, Lcom/nemustech/regina/AppInfoManager;->access$900(Lcom/nemustech/regina/AppInfoManager;)Ljava/util/List;

    move-result-object v4

    new-instance v5, Lcom/nemustech/regina/AppInfoManager$AppInfoComparator;

    invoke-direct {v5}, Lcom/nemustech/regina/AppInfoManager$AppInfoComparator;-><init>()V

    invoke-static {v4, v5}, Ljava/util/Collections;->sort(Ljava/util/List;Ljava/util/Comparator;)V

    .line 599
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    invoke-static {v4}, Lcom/nemustech/regina/AppInfoManager;->access$600(Lcom/nemustech/regina/AppInfoManager;)Lcom/nemustech/regina/ReginaLauncher;

    move-result-object v4

    invoke-virtual {v4}, Lcom/nemustech/regina/ReginaLauncher;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v3

    .line 600
    .local v3, resolver:Landroid/content/ContentResolver;
    sget-object v4, Lcom/nemustech/regina/ReginaSettings$SecretComponentNames;->CONTENT_URI:Landroid/net/Uri;

    const/4 v5, 0x0

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    invoke-virtual/range {v3 .. v8}, Landroid/content/ContentResolver;->query(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v14

    .line 602
    .local v14, cursor:Landroid/database/Cursor;
    :try_start_0
    const-string v4, "packageName"

    invoke-interface {v14, v4}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v18

    .line 603
    .local v18, packageNameIndex:I
    const-string v4, "className"

    invoke-interface {v14, v4}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v11

    .line 604
    .local v11, classNameIndex:I
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    invoke-static {v4}, Lcom/nemustech/regina/AppInfoManager;->access$1100(Lcom/nemustech/regina/AppInfoManager;)Ljava/util/List;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/List;->clear()V

    .line 605
    :goto_1
    invoke-interface {v14}, Landroid/database/Cursor;->moveToNext()Z

    move-result v4

    if-eqz v4, :cond_2

    .line 606
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    invoke-static {v4}, Lcom/nemustech/regina/AppInfoManager;->access$1100(Lcom/nemustech/regina/AppInfoManager;)Ljava/util/List;

    move-result-object v4

    new-instance v5, Landroid/content/ComponentName;

    move-object v0, v14

    move/from16 v1, v18

    invoke-interface {v0, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    invoke-interface {v14, v11}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v5, v6, v7}, Landroid/content/ComponentName;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-interface {v4, v5}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    goto :goto_1

    .line 612
    .end local v11           #classNameIndex:I
    .end local v18           #packageNameIndex:I
    :catchall_0
    move-exception v4

    invoke-interface {v14}, Landroid/database/Cursor;->close()V

    throw v4

    .restart local v11       #classNameIndex:I
    .restart local v18       #packageNameIndex:I
    :cond_2
    invoke-interface {v14}, Landroid/database/Cursor;->close()V

    .line 614
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    invoke-static {v4}, Lcom/nemustech/regina/AppInfoManager;->access$1200(Lcom/nemustech/regina/AppInfoManager;)V

    .line 615
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    const/4 v5, 0x1

    invoke-static {v4, v5}, Lcom/nemustech/regina/AppInfoManager;->access$002(Lcom/nemustech/regina/AppInfoManager;Z)Z

    .line 616
    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->mStopped:Z

    move v4, v0

    if-nez v4, :cond_3

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->this$0:Lcom/nemustech/regina/AppInfoManager;

    move-object v4, v0

    invoke-virtual {v4}, Lcom/nemustech/regina/AppInfoManager;->startBitmapCacheLoader()V

    .line 618
    .end local v3           #resolver:Landroid/content/ContentResolver;
    .end local v11           #classNameIndex:I
    .end local v13           #count:I
    .end local v14           #cursor:Landroid/database/Cursor;
    .end local v15           #i:I
    .end local v18           #packageNameIndex:I
    :cond_3
    const/4 v4, 0x0

    move v0, v4

    move-object/from16 v1, p0

    iput-boolean v0, v1, Lcom/nemustech/regina/AppInfoManager$AppLoader;->mRunning:Z

    .line 619
    const/4 v4, 0x1

    move v0, v4

    move-object/from16 v1, p0

    iput-boolean v0, v1, Lcom/nemustech/regina/AppInfoManager$AppLoader;->mStopped:Z

    .line 620
    return-void
.end method

.method public stop()V
    .locals 1

    .prologue
    .line 550
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->mRunning:Z

    .line 551
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/nemustech/regina/AppInfoManager$AppLoader;->mStopped:Z

    .line 552
    return-void
.end method
